﻿using System.ComponentModel.DataAnnotations;
using Dexter.Core.Helpers;
using Dexter.Web.Mvc.ViewModel.Resources;

namespace Dexter.Web.Mvc.ViewModel.FrontEnd.Binders {
	public class ContactBinder {
		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		[StringLength ( 500, ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "MaximumLengthExceeded" )]
		public string Name { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		[StringLength ( 250, ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "MaximumLengthExceeded" )]
		[RegularExpression ( KnownRegex.MailAddress, ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "InvalidFormat" )]
		public string Email { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		public string Subject { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		public string Message { get; set; }

		static readonly ContactBinder emptyInstance = new ContactBinder ( );

		public static ContactBinder EmptyInstance {
			get { return emptyInstance; }
		}
	}
}